<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增加班')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-work-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">员工姓名：</label>
                <div class="col-sm-8">
                    <input name="userName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-8">
                    <!--部门编号 隐藏-->
                    <input id="treeId" name="deptId" class="form-control" type="hidden">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">所属组织：</label>
                <div class="col-sm-8">
                    <input name="belongOrganization" id="treeName"  class="form-control" type="text" onclick="selectDeptTree()">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">职位：</label>
                <div class="col-sm-8">
                    <input name="post" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">加班日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="overWorkDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">加班类型：</label>
                <div class="col-sm-8">
                    <select name="overWorkType" class="form-control m-b" th:with="type=${@dict.getType('sys_over_work_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">申请日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="applyDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">加班开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="beginTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">加班结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">休息时长：</label>
                <div class="col-sm-8">
                    <input name="restTime" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">加班小时数：</label>
                <div class="col-sm-8">
                    <input name="overWorkHour" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">加班原因：</label>
                <div class="col-sm-8">
                    <input name="overWorkReason" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">补偿方式：</label>
                <div class="col-sm-8">
                    <select name="rewardType" class="form-control m-b" th:with="type=${@dict.getType('sys_reward_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remarks" class="form-control" type="text">
                </div>
            </div>
            <!--<div class="form-group">    -->
                <!--<label class="col-sm-3 control-label is-required">员工编号：</label>-->
                <!--<div class="col-sm-8">-->
                    <!--<input name="userId" class="form-control" type="text" required>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="form-group">    -->
                <!--<label class="col-sm-3 control-label is-required">租户编号：</label>-->
                <!--<div class="col-sm-8">-->
                    <!--<input name="tenantId" class="form-control" type="text" required>-->
                <!--</div>-->
            <!--</div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/work"
        $("#form-work-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-work-add').serialize());
            }
        }

        /* 用户管理-修改-选择部门树 */
        function selectDeptTree() {
            console.log("部门树")
            var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
            $("#deptId").val(deptId);
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "350",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }

        $("input[name='overWorkDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='applyDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='beginTime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            todayBtn:  true,
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            todayBtn:  true,
            autoclose: true
        });
    </script>
</body>
</html>